{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<!--<link href="{__STATIC__}/home/other/formSelects-v4.css" rel="stylesheet" />-->
<!--<script src="{__STATIC__}/home/other/jquery.min.js"></script>-->
<!--<script src="{__STATIC__}/home/other/formSelects-v4.min.js"></script>-->
<style>
    .layui-tree-entry {
        font-size: 15px;
        line-height: 24px
    }

    .layui-tree-set {
        padding: 2px 0
    }

    .layui-tree-iconClick .layui-icon {
        color: #1E9FFF
    }

    .layui-icon layui-icon-file {
        font-size: 16px;
    }

    .layui-tree-icon {
        height: 15px;
        width: 15px;
        text-align: center;
        border: 1px solid #1E9FFF;
        color: #1E9FFF
    }

    .layui-tree-line .layui-tree-set .layui-tree-set:after {
        top: 18px;
    }

    .tree-left {
        width: 200px;
        float: left;
        height: calc(100% - 30px);
        overflow: scroll;
        border: 1px solid #eeeeee;
        background-color: #FAFAFA;
        padding: 12px 12px 12px 5px;
    }

    .tree-left h3 {
        font-size: 16px;
        height: 30px;
        padding-left: 10px;
        font-weight: 800
    }

    .gougu-upload-files {
        background-color: #ffffff;
        border: 1px solid #e4e7ed;
        color: #c0c4cc;
        cursor: not-allowed;
        padding: 0 12px;
        width: 180px;
        box-sizing: border-box;
        display: inline-block;
        font-size: inherit;
        height: 38px;
        line-height: 35px;
        margin-right: 8px;
        border-radius: 2px;
    }

    .gougu-upload-tips {
        color: #969696
    }

    .layui-form-item {
        margin-bottom: 8px;
    }

    .layui-input-block {
        min-height: 24px;
    }
</style>
<div class="layui-col-lg12 layui-col-md12 layui-col-sm12">
<!--    <div class="layui-col-lg2 layui-col-md2 layui-col-sm2 layui-col-xl2 layui-col-sm2 layui-col-xs2 layui-padding-2">-->
<!--        <h3>物料分类</h3>-->
<!--        <div id="ID-tree-demo-showLine"></div>-->
<!--    </div>-->
<!--    <div class="layui-col-lg10 layui-col-md10 layui-col-xl10 layui-col-sm10 layui-col-sm10 layui-col-xs10">-->
    <div class="">
        <form class="layui-form gg-form-bar border-t border-x">
<!--            <div class="layui-input-inline" style="width:500px;">-->
<!--                <input type="text" name="keywords" placeholder="编码/品牌/品名/型号/订货号/税收编码/采购合同" class="layui-input" autocomplete="off"/>-->
<!--            </div>-->
            <div class="layui-input-inline" style="width:300px;">
                <input type="text" name="orderNum" placeholder="单号" class="layui-input" autocomplete="off"/>
            </div>
            <div class="layui-input-inline" style="width:300px;">
                <input type="text" name="sureName" placeholder="入库人" class="layui-input" autocomplete="off"/>
            </div>
            <div class="layui-input-inline" style="width:300px;">
                <input type="text" name="times" placeholder="入库时间" id="times" readonly class="layui-input" autocomplete="off"/>

            </div>
            <div class="layui-input-inline" style="width:300px;">
                <select name="tType" lay-search xm-select="warehouse_id" lay-filter="warehouse_id">
                    <option value="">状态</option>
                    <option value="1">草稿</option>
                    <option value="2">已确认</option>
                </select>
            </div>

            <div class="layui-input-inline" style="width:300px;">
                <input type="text" name="brand" placeholder="品牌" class="layui-input" autocomplete="off"/>
            </div>
            <div class="layui-input-inline" style="width:300px;">
                <input type="text" name="name" placeholder="品名" class="layui-input" autocomplete="off"/>
            </div>
            <div class="layui-input-inline" style="width:300px;">
                <input type="text" name="specs" placeholder="型号" class="layui-input" autocomplete="off"/>
            </div>
            <div class="layui-input-inline" style="width:300px;">
                <input type="text" name="buyCode" placeholder="订货号" class="layui-input" autocomplete="off"/>
            </div>


            <div class="layui-input-inline" style="width:150px;">
                <button class="layui-btn layui-btn-normal" lay-submit="" id="webf" lay-filter="webformIndex"><i
                        class="layui-icon layui-icon-search mr-1"></i>搜索
                </button>
                <button type="reset" class="layui-btn layui-btn-reset" lay-filter="reset">清空</button>
            </div>
        </form>
        <div class="p-3">
            <div>
                <table class="layui-hide" id="treeTable" lay-filter="treeTable"></table>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="toolbarDemo">
    <button class="layui-btn layui-btn-sm add-menu" lay-event="add">+ 添加</button>
    <button class="layui-btn layui-btn-sm layui-btn-danger " lay-event="dels" type="button">删除</button>

</script>
<script type="text/html" id="actionBar">
    <button class="layui-btn layui-btn-normal  layui-btn-xs"  lay-event="edit">编辑</button>
        <button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="info">详情</button>
</script>

{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script type="text/javascript">


</script>
<script>
    const moduleInit = ['tool'];

    function gouguInit() {
        var treeTable = layui.treeTable, tool = layui.tool, form = layui.form;
        var upload = layui.upload;
        var tableIns = treeTable.render({
            elem: '#treeTable'
            , url: "{:url('index')}"
            , toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports']
            , tree: { // treeTable 特定属性集
                customName: {name: 'name'},
                data: {},
                view: {showIcon: false},
                async: {},
                callback: {}
            }
            , cellMinWidth: 80
            , cols: [[
                {type: 'checkbox', fixed: 'left'},
                 {field: 'orderNum', title: '单号'}
                , {field: 'sureName', title: '入库人'}
                , {field: 'checkTime', title: '入库时间'}
                , {field: 'brand', title: '品牌'}
                , {field: 'mdName', title: '品名'}
                , {field: 'specs', title: '型号'}
                , {field: 'buyCode', title: '订货号'}
                , {field: 'unit', title: '单位'}
                , {field: 'num', title: '入库数量'}
                , {field: 'sodPrice', title: '单价'}
                , {field: 'remark', title: '备注'}
                , {field: 'status', title: '状态',templet:function (d) {
                  return   d.status==1?'草稿':'已确认';
                    }}
                , {title: '操作',fixed: 'right',width: 200,  align: 'center'
                    , toolbar: '#actionBar'
                }
            ]],
            done:function (res) {

            }
            , page: true,
            limits: [10, 20, 50, 80, 100, 200, 500, 1000, 2000, 5000, 10000],
        });
        //监听搜索提交
        form.on('submit(webformIndex)', function (data) {
            tableIns.reload({
                where: data.field,
                page: {
                    curr: 1
                }
            });
            return false;
        });
        //表头工具栏事件
        // $('.add-menu').on('click', function () {
        //     tool.side("/home/BomForm/add");
        //     return;
        // });

        //操作按钮
        treeTable.on('tool(treeTable)', function (obj) {
            console.log(obj);
            if (obj.event === 'add') {
                // tool.side('/home/BomForm/add?pid=' + obj.data.id);
                return;
            }
            if (obj.event === 'edit') {
                tool.side('add?id=' + obj.data.orderId);
                return;
            }
            if (obj.event === 'info') {
                tool.side('info?id=' + obj.data.orderId);
                return;
            }
            if (obj.event === 'del') {
                layer.confirm('确定要删除吗?', {icon: 3, title: '提示'}, function (index) {
                    let callback = function (e) {
                        layer.msg(e.msg);
                        if (e.code == 0) {
                            obj.del();
                        }
                    }
                    // tool.delete("/home/BomForm/delete", {id: obj.data.id}, callback);
                    layer.close(index);
                });
            }
            if (obj.event === 'forbid') {
                layer.confirm('确定要禁用吗?', {icon: 3, title: '提示'}, function (index) {
                    let callback = function (e) {
                        layer.msg(e.msg);
                        if (e.code == 0) {
                            tableIns.reload();
                        }
                    }
                    // tool.post("/home/BomForm/doCheck", { id: obj.data.id,status: 2}, callback);
                    layer.close(index);
                });
            }
            if (obj.event === 'resume') {
                layer.confirm('确定要启用吗?', {icon: 3, title: '提示'}, function (index) {
                    let callback = function (e) {
                        layer.msg(e.msg);
                        if (e.code == 0) {
                            tableIns.reload();
                        }
                    }
                    // tool.post("/home/BomForm/doCheck", { id: obj.data.id,status: 1}, callback);
                    layer.close(index);
                });
            }
        });
        treeTable.on('toolbar(treeTable)', function (obj) {
            var checkStatus = treeTable.checkStatus(obj.config.id);
            console.log(checkStatus)
            switch (obj.event) {
                case 'add':
                    tool.side('add')
                    break;
                case 'dels':
                    var data = checkStatus.data;
                    var ids = []
                    if (data.length) {
                        data.forEach(function (value, index) {
                            console.log('value', value)
                            ids.push(value.orderId)
                        })
                        layer.confirm('确定要删除吗?', {icon: 3, title: '提示'}, function (index) {
                            let callback = function (e) {
                                layer.msg(e.msg);
                                if (e.code == 0) {
                                    tableIns.reload();
                                }
                            }
                            tool.delete("delete", {id: ids.join(',')}, callback);
                            layer.close(index);
                        });

                    } else {
                        layer.msg('请选择数据');
                    }

                    break;
                case 'import':

                    break;

            }
            ;
        })
        var tree = layui.tree;

        layui.laydate.render({
            elem:'#times',
            range:'~'
            }
        )
    }
function testaa(obj) {
        console.log('obj',obj)
}
    // function getLocal(id) {
    //     $("#locator").empty();
    //         if (id.length){
    //             ids=id.join(',')
    //             var optionStr="<option value=''>请选择数据</option>";
    //             $.ajax({
    //                 url:'/home/api/getWarHoseDetail',
    //                 type:'post',
    //                 dataType:'json',
    //                 data:{id:ids},
    //                 success:function (res) {
    //                     if (res.code==0){
    //                         let data=res.data;
    //                         for(var i=0;i<data.length;i++){
    //                             optionStr+=" <option value='"+data[i].id+"'>"+data[i].name+"</option>";
    //                         }
    //                     }else {
    //                     }
    //                     $("#locator").append(optionStr);
    //                     formSelects.render('locator');
    //                     formSelects.btns('locator',[]);
    //                 }
    //
    //             })
    //         }else {
    //             $("#locator").append(" <option value=''>请选先选择仓库</option>");
    //             formSelects.render('locator');
    //             formSelects.btns('locator',[]);
    //         }
    //
    //
    // }

</script>
{/block}
<!-- /脚本 -->